package com.bean;

import com.utils.DateUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Administrator
 */
public class Message {
    private Integer id;

    private Integer studentId;

    private Integer teacherId;

    private String status;

    private String studentName;

    private String teacherName;

    private String title;

    private String content;

    private String createTime;

    public Message() {
    }

    public Message(Integer studentId, Integer teacherId, Integer status, String title, String content, Date createTime) {
        this.studentId = studentId;
        this.teacherId = teacherId;
        this.status = (status == 0 ? "学生" : "教师");
        this.title = title;
        this.content = content;
        if (createTime == null) {
            this.createTime = null;
        } else {
            this.createTime = DateUtils.format(createTime);
        }
    }

    @Override
    public String toString() {
        return "Message{" +
                "id=" + id +
                ", studentId=" + studentId +
                ", teacherId=" + teacherId +
                ", status='" + status + '\'' +
                ", studentName='" + studentName + '\'' +
                ", teacherName='" + teacherName + '\'' +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", createTime='" + createTime + '\'' +
                '}';
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getStudentId() {
        return studentId;
    }

    public void setStudentId(Integer studentId) {
        this.studentId = studentId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getCreateTime() {
        if (createTime == null) {
            return null;
        } else {
            return DateUtils.parse(createTime);
        }

    }

    public void setCreateTime(Date createTime) {
        if (createTime == null) {
            this.createTime = null;
        } else {
            this.createTime = DateUtils.format(createTime);
        }

    }

    public Integer getStatus() {
        return (status == "学生" ? 0 : 1);
    }

    public void setStatus(Integer status) {
        this.status = (status == 0 ? "学生" : "教师");
    }

    public Integer getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(Integer teacherId) {
        this.teacherId = teacherId;
    }

}